layui.use('laydate', function () {
    var laydate = layui.laydate;
    laydate.render({
        elem: '#test16'
        , type: 'datetime'
        , range: '-'
        , format: 'yyyy年M月d日'
        , theme: '#8269E4'
        , done: function (value, date) {
            //出发日期
            $(".goDate1").text(value)
            // layer.alert('你选择的日期是：' + value + '<br>获得的对象是' + JSON.stringify(date));
            console.log(value)
        }
    });
});


//目的地
$(".destination").blur(function () {
    $(".destination1").text($(".destination").val())
})
//出发地
$(".start").blur(function () {
    console.log($(".start").val())
    $(".start1").text($(".start").val())
})

getPerson()

//出发人数
function getPerson() {
    $(".person").text("")
    var adult = $(".adult").val()
    var children = $(".children").val()
    var old = $(".old").val()
    var person = adult + " 成人 " + children + " 儿童 " + old + " 老人";
    $(".person").text(person)
}

var custom;
//定制类型
var radioWrap = document.querySelector(".radio-wrap");
radioWrap.onclick = function (event) {
    var ele = event.target;
    console.log(ele);
    console.log(ele.nodeName);
    if (ele.nodeName == 'SPAN' && ele.className == 'radio') {
        var radioBoxs = document.querySelectorAll(".radio-box");
        for (var i = 0; i < radioBoxs.length; i++) {
            var radioBox = radioBoxs[i]
            radioBox.firstElementChild.className = "radio";
        }
        ele.className = 'radio on';
        custom = ele.parentElement.innerText;
        console.log(custom)
        $(".customOn").text(custom)
        $(".customOm1").text(custom)

    }
}
//人均预算
$(".min-price").blur(function () {
    var minPrice = $(".min-price").val() + "-";
    $(".price").text(minPrice)
})
$(".max-price").blur(function () {
    var maxPrice = $(".max-price").val();
    $(".price").append(maxPrice)
})
//需要提供的服务
var checkbox = document.querySelector(".checkbox");
checkbox.onclick = function (event) {
    var ele = event.target;
    console.log(ele);
    console.log(ele.nodeName);
    if (ele.className == 'el-checkbox-button__inner') {
        ele.className = "el-checkbox-button__inner_on";
    } else if (ele.className == 'el-checkbox-button__inner_on') {
        console.log("111")
        ele.className = "el-checkbox-button__inner";
    }
    checkBox();

}

function checkBox() {
    var checkboxs = document.querySelectorAll(".el-checkbox-button__inner_on");
    console.log(checkboxs)
    $(".checkBox").text("")
    for (var i = 0; i < checkboxs.length; i++) {
        var checkBox = checkboxs[i];

        $(".checkBox").append(checkBox.innerText + " ")
    }
}

//其他需求
$(".text").blur(function () {
    $(".text1").text($(".text").val())
})
//联系人姓名
$(".myname").blur(function () {
    console.log($(".myname").val())
    $(".name1").text($(".myname").val())
})
//手机号
$(".phone").blur(function () {
    console.log($(".phone").val())
    $(".phone1").text($(".phone").val())
})

//加减号
var personNumber = document.querySelector(".personNumber");
personNumber.onclick = function (event) {
    var ele = event.target;
    // console.log(ele);
    // console.log(ele.nodeName);
    if (ele.nodeName == 'I' && ele.innerText == "+") {
        var number = ele.parentElement.nextElementSibling.firstElementChild.value;
        ele.parentElement.nextElementSibling.firstElementChild.value = ++number
    } else if (ele.nodeName == 'I' && ele.innerText == "-") {
        var number = ele.parentElement.nextElementSibling.nextElementSibling.firstElementChild.value;
        console.log(ele.parentElement.nextElementSibling.nextElementSibling.firstElementChild.className)
        if (ele.parentElement.nextElementSibling.nextElementSibling.firstElementChild.className == 'el-input__inner adult'
            && number == 1) {
            ele.parentElement.nextElementSibling.nextElementSibling.firstElementChild.value = number
        } else if (ele.parentElement.nextElementSibling.nextElementSibling.firstElementChild.className == 'el-input__inner children'
            && number == 0) {
            ele.parentElement.nextElementSibling.nextElementSibling.firstElementChild.value = number
        }else if(ele.parentElement.nextElementSibling.nextElementSibling.firstElementChild.className == 'el-input__inner old'
            && number == 0) {
            ele.parentElement.nextElementSibling.nextElementSibling.firstElementChild.value = number
        }else {
            ele.parentElement.nextElementSibling.nextElementSibling.firstElementChild.value = --number
        }

    }
    getPerson()
};

//点击名称进入首页
$(".nav_userName").click(function () {

    $.ajax({
        url: "/order/getId",
        type: "GET",
        datatype: "json",
        success: function (data) {
            console.log(data.data)
            window.sessionStorage.setItem("cusid", data.data)
            $(location).attr('href', 'order');
        }

    })

});